var React = require('react');
var AppView = require('../../common/component/view/app-view.node');
var ModalDialog = require('../../common/component/dialog/modal-dialog.node');
var ModalBody = require('../../common/component/dialog/modal-body.node');
var ModalFooter = require('../../common/component/dialog/modal-footer.node');

module.exports = <>
  <AppView viewTitle="${t('ui.security.role.title.roleManagement')}">
    <link href="${appCss('static/app/security/role-management.css')}" rel="stylesheet" />

    <div className="x-search-bar">
      <form>
        <div className="form-row align-items-center">

          <div className="col-auto">
            <label className="sr-only" htmlFor="roleCode"></label>
            <div className="input-group mb-2">
              <div className="input-group-prepend">
                <div className="input-group-text">{"${t('ui.security.role.field.roleCode')}"}</div>
              </div>
              <input type="text" className="form-control" id="roleCode" data-x-name="searchField.roleCode"
                data-x-type="autoTrimText" />
            </div>
          </div>

          <div className="col-auto">
            <label className="sr-only" htmlFor="roleName"></label>
            <div className="input-group mb-2">
              <div className="input-group-prepend">
                <div className="input-group-text">{"${t('ui.security.role.field.roleName')}"}</div>
              </div>
              <input type="text" className="form-control" id="roleName" data-x-name="searchField.roleName"
                data-x-type="autoTrimText" />
            </div>
          </div>

          <div className="col-auto">
            <label className="sr-only" htmlFor="remark"></label>
            <div className="input-group mb-2">
              <div className="input-group-prepend">
                <div className="input-group-text">{"${t('ui.security.resource.field.remark')}"}</div>
              </div>
              <input type="text" className="form-control" id="remark" data-x-name="searchField.remark"
                data-x-type="autoTrimText" />
            </div>
          </div>

          {/* 查询按钮 */}
          <div className="col-auto">
            <button type="button" className="btn btn-primary mb-2" data-x-ui="searchBtn">
              {"${t('ui.system.common.btn.search')}"}
            </button>
          </div>
        </div>
      </form>
    </div>

    <div className="x-tool-bar">
      <button type="button" className="btn btn-outline-primary mb-2 btn-sm" data-x-ui="createBtn">
        {"${t('ui.system.common.btn.create')}"}
      </button>
    </div>

    <table data-x-ui="roleTable" className="x-table-custom">
      <thead>
        <tr>
          <th data-field="id" data-visible="false">ID</th>
          <th data-field="roleCode">{"${t('ui.security.role.field.roleCode')}"}</th>
          <th data-field="roleName">{"${t('ui.security.role.field.roleName')}"}</th>
          <th data-field="effectiveFlagDesc">{"${t('ui.system.common.field.effectiveFlag')}"}</th>
          <th data-field="remark">{"${t('ui.system.common.field.remark')}"}</th>
          <th>{"${t('ui.system.common.field.operate')}"}</th>
        </tr>
      </thead>
    </table>

    {/* "新建角色"弹出框 */}
    <div data-x-ui="newRoleDialog" className="modal" tabIndex="-1">
      <ModalDialog dialogTitle="${t('ui.security.role.dialog.newRole')}">
        <ModalBody>
          <form>
            <div className="form-group x-form-required">
              <label htmlFor="roleCode">{"${t('ui.security.role.field.roleCode')}"}</label>
              <input type="text" className="form-control" id="roleCode" name="roleCode" data-x-name="new.roleCode"
                placeholder={"${t('ui.system.common.placeholder.inputCodeLimitLength', 1, 50)}"} />
            </div>
            <div className="form-group x-form-required">
              <label htmlFor="roleName">{"${t('ui.security.role.field.roleName')}"}</label>
              <input type="text" className="form-control" id="roleName" name="roleName" data-x-name="new.roleName"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 1, 20)}"} />
            </div>

            <div className="form-group x-form-required">
              <label htmlFor="effectiveFlag">{"${t('ui.system.common.field.effectiveFlag')}"}</label>
              <select className="form-control" id="effectiveFlag" name="effectiveFlag" data-x-name="new.effectiveFlag"
                defaultValue="true">
                <option value="true">{"${t('ui.system.common.option.effectiveFlag.true')}"}</option>
                <option value="false">{"${t('ui.system.common.option.effectiveFlag.false')}"}</option>
              </select>
            </div>
            <div className="form-group">
              <label htmlFor="remark">{"${t('ui.system.common.field.remark')}"}</label>
              <input type="text" className="form-control" id="remark" name="remark" data-x-name="new.remark"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 0, 200)}"} />
            </div>
          </form>
        </ModalBody>
        <ModalFooter confirmLabel="${t('ui.system.common.btn.save')}" cancelLabel="${t('ui.system.common.btn.cancel')}" />
      </ModalDialog>
    </div>

    {/* "编辑角色"弹出框 */}
    <div data-x-ui="editRoleDialog" className="modal" tabIndex="-1">
      <ModalDialog dialogTitle="${t('ui.security.role.dialog.editRole')}">
        <ModalBody>
          <form>
            <input type="hidden" id="id" name="id" data-x-name="edit.id" />
            <input type="hidden" id="versionNumber" name="versionNumber" data-x-name="edit.versionNumber" />

            <div className="form-group x-form-required">
              <label htmlFor="roleCode">{"${t('ui.security.role.field.roleCode')}"}</label>
              <input type="text" className="form-control" id="roleCode" name="roleCode" data-x-name="edit.roleCode"
                placeholder={"${t('ui.system.common.placeholder.inputCodeLimitLength', 1, 50)}"} />
            </div>
            <div className="form-group x-form-required">
              <label htmlFor="roleName">{"${t('ui.security.role.field.roleName')}"}</label>
              <input type="text" className="form-control" id="roleName" name="roleName" data-x-name="edit.roleName"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 1, 20)}"} />
            </div>

            <div className="form-group x-form-required">
              <label htmlFor="effectiveFlag">{"${t('ui.system.common.field.effectiveFlag')}"}</label>
              <select className="form-control" id="effectiveFlag" name="effectiveFlag" data-x-name="edit.effectiveFlag"
                defaultValue="true">
                <option value="true">{"${t('ui.system.common.option.effectiveFlag.true')}"}</option>
                <option value="false">{"${t('ui.system.common.option.effectiveFlag.false')}"}</option>
              </select>
            </div>
            <div className="form-group">
              <label htmlFor="remark">{"${t('ui.system.common.field.remark')}"}</label>
              <input type="text" className="form-control" id="remark" name="remark" data-x-name="edit.remark"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 0, 200)}"} />
            </div>
          </form>
        </ModalBody>
        <ModalFooter confirmLabel="${t('ui.system.common.btn.save')}" cancelLabel="${t('ui.system.common.btn.cancel')}" />
      </ModalDialog>
    </div>

    {/* "授权"弹出框 */}
    <div data-x-ui="authorizeDialog" className="modal" tabIndex="-1">
      <ModalDialog dialogTitle="${t('ui.security.role.dialog.authorize')}">
        <ModalBody>
          <div data-x-ui="menuTree" className="menu-tree"></div>
        </ModalBody>
        <ModalFooter confirmLabel="${t('ui.system.common.btn.save')}" cancelLabel="${t('ui.system.common.btn.cancel')}" />
      </ModalDialog>
    </div>

    <script src="${appJs('app/menu/common/convert-to-tree-data.js')}" type="text/javascript"></script>
    <script src="${appJs('app/security/role/authorize-dialog.js')}" type="text/javascript"></script>
    <script src="${appJs('app/security/role/role-management.js')}" type="text/javascript"></script>
  </AppView>
</>
